// Javascript Database Util class
function DatabaseUtil( flashID )
{
	var _database;
	
	var _id = flashID;
	this.id = _id;
	
	this.createDatabase = function(name, version, description, size)
	{
		_database = window.openDatabase(name, version, description, size);
		
		console.log(_database);
	}

	this.executeQuery = function(name, query, variables)
	{
		_database.transaction(
			function(tx) 
			{    
				tx.executeSql(query, variables, onSucces, onError)
			}
		);
		
		console.log("executeQuery " + arguments);
	}
	
	this.getFlashMovie = function(movieName)
	{   
		document.getElementById(movieName).setAttribute("name", movieName);
		var isIE = navigator.appName.indexOf("Microsoft") != -1;   
		return (isIE) ? window[movieName] : document[movieName];  
	} 

	function onSucces (tx, result) 
	{ 
		getFlashMovie(id).onDatabaseCallSucces(tx, result); 
		
		console.log(tx, result);
	}
	
	function onError(tx, result) 
	{ 
		getFlashMovie(id).onDatabaseCallFailed(tx, result); 
		
		console.log(tx, result);
	}

}
